home *** CD-ROM | disk | FTP | other *** search
/ VRML Browsing & Building Cyberspace / VRML - Browsing and Building Cyberspace.iso / examples / 20.wrl next >
Text File  |  1995-06-29  |  4KB  |  118 lines

  1. #VRML V1.0 ascii
  2.  
  3. # Example twenty - We texture map the Moon manually
  4.  
  5. # Here comes the Sun
  6. # The Separator node groups everything within it together
  7. DEF SOLAR_SYSTEM Separator {
  8.  
  9.     # The material will effect all subsequent nodes
  10.     # The sun is yellow, isn't it?  Additive color means red + green = yellow
  11.     # We're switching to emissive color because the Sun gives off light.
  12.     Material {
  13.         emissiveColor 1 1 0        # The Sun emits lots of yellow light
  14.     }
  15.  
  16.     # We'll make the Sun shine here
  17.     # A PointLight shines equally in all directions, like the Sun does.
  18.     #DEF SUNLIGHT PointLight {
  19.         #intensity 1        # The Sun is way bright
  20.         #color 1 1 0.9   # Sunlight is basically white, even though the Sun is yellow.
  21.     #}
  22.  
  23.     # The WWWAnchor node is a group node
  24.     # This means that all objects within it are linked with the anchor's URL
  25.     # We want to link the Sun, so the Sun's Sphere node goes inside of it.
  26.     # Using the description field, we provide context for the user
  27.     # The DEF node attaches the name "SUN" to the WWWAnchor group
  28.     DEF SUN WWWAnchor {
  29.         name "http://www.w3.org/" # The root URL of the World Wide Web
  30.         description "A link from the Sun to W3.ORG" # Decriptive text
  31.  
  32.         Sphere {
  33.             radius 10
  34.         }
  35.     }
  36.  
  37.     # We place the Earth within it's own Separator
  38.     # To keep everything good and isolated
  39.     Separator {
  40.  
  41.         # Let's move things out of the way here
  42.         Transform {
  43.             translation 0 20 20
  44.         }
  45.  
  46.         # Color the Earth blue, and make it absorb light
  47.         # But also make it a reflective, like water
  48.         DEF EARTH_MATERIAL Material {
  49.             diffuseColor 0 0 1 # Big blue marble
  50.             specularColor 0.9 0.9 0.9 # And a little more shiny
  51.             shininess 0.9 # Water is rather shiny
  52.         }
  53.  
  54.         # The WWWAnchor node is a group node
  55.         # This means that all objects within it are linked with the anchor's URL
  56.         # We want to link the Earth, so the Earth's Sphere node goes inside of it.
  57.         # Using the description field, we provide context for the user
  58.         # The DEF node attaches the name "Earth" to the WWWAnchor node
  59.         DEF EARTH WWWAnchor {
  60.             name "http://hyperreal.com/~mpesce/book/examples/second.wrl" # Another world
  61.             description "A link to another world" # Decriptive text
  62.  
  63.             # Finally, create the earth
  64.             Sphere {
  65.                 radius 2    # Little Earth
  66.             }
  67.         }
  68.  
  69.         # The Moon gets its own Separator
  70.         # Because we really do keep everything separate
  71.         Separator {
  72.  
  73.             # The Moon is just outside the Earth
  74.             Transform {
  75.                 translation 4 4 0
  76.             }
  77.  
  78.             # Color the Moon grey, make it absorb light
  79.             # It's a little shiny, but not much
  80.             Material {
  81.                 diffuseColor 0.7 0.7 0.7
  82.                 shininess 0.3
  83.             }
  84.  
  85.             # This is a sample texture map
  86.             # Just to show how it all works.
  87.             # Using it, you'll get a 2 x 4 image
  88.             # It's in black/gray/white to make it look like a faux lunar surface
  89.             Texture2 {
  90.                 # Define a 4 x 4 pixel texture map using RGB values
  91.                 image 4 4 3 
  92.  
  93.                 # Here's the map, from lower left to upper right
  94.                 0xC0C0C0 0x808080 0xFFFFFF 0x404040 # Bottom row
  95.                 0x808080 0x202020 0x808080 0xC0C0C0 # Lower Middle Row
  96.                 0x202020 0x808080 0xFFFFFF 0x808080 # Upper Middle Row
  97.                 0x808080 0xC0C0C0 0x808080 0x202020 # Upper Row
  98.             }
  99.  
  100.             # The WWWAnchor node is a group node
  101.             # This means that all objects within it are linked with the anchor's URL
  102.             # We want to link the Moon, so the Moon's Sphere node goes inside of it.
  103.             # Using the description field, we provide context for the user
  104.             # The DEF node attaches the name "Moon" to the WWWAnchor node
  105.             DEF Moon WWWAnchor {
  106.                 name "http://www.cyborganic.com:80/People/paul/The_new_dogs/pescewrd.au"
  107.                 description "Sounds from a talk about VRML"
  108.  
  109.                 # And now, create the Moon
  110.                 Sphere {
  111.                     radius 1    # Tiny Moon
  112.                 }
  113.             }
  114.         }
  115.     }
  116. }
  117.  
  118.